﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Core.Interfaces;
using Core.Interfaces.IDAO;
using Core.Unity;
using Microsoft.Practices.Unity;

namespace Core.Reports
{
    public partial class FirstReport : Form
    {
        private ICustomerDAO _customerDAO;
        private IOwnedBuildingDAO _ownedBuildingDAO;
        private List<IOwnedBuilding> ob_in_time = new List<IOwnedBuilding>();
        public FirstReport()
        {
            InitializeComponent();
            _customerDAO = ResolverContainer.Resolver.Resolve<ICustomerDAO>();
            _ownedBuildingDAO = ResolverContainer.Resolver.Resolve<IOwnedBuildingDAO>();
            iOwnedBuildingBindingSource.DataSource = ob_in_time;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DateTime start = dateTimePicker1.Value;
            DateTime end = dateTimePicker2.Value;
            var ob = _ownedBuildingDAO.GetAll(true);
            ob_in_time = ob.Where(ownedBuilding => (ownedBuilding.DayOfBuy > start) && (ownedBuilding.DayOfBuy < end)).ToList();
            iOwnedBuildingBindingSource.DataSource = ob_in_time;
            iOwnedBuildingBindingSource.ResetBindings(false);
        }

        private void iCustomerBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }
    }
}
